package development.hdk.node;

import android.R.bool;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Point;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import development.hdk.mindmapfornandroid.Attributes;
import development.hdk.mindmapfornandroid.CommonResources;;

public class Line extends View
{
  int b;
  Point childP;
  float cnX;
  float cnY;
  private CommonResources commonResources;
  float cpX;
  float cpY;
  int h;
  private Node node;
  private int nodeX;
  private int nodeY;
  private Paint paint = new Paint(1);
  public Node parent;
  Point parentP;
  private int parentX;
  private int parentY;
  Path path = new Path();
  int t;
  private final int thickness = 3;
  int w;

  public Line(Context paramContext, Node paramNode, CommonResources paramCommonResources)
  {
    super(paramContext);
    this.node = paramNode;
    this.parent = paramNode.getParentNode();
    this.commonResources = paramCommonResources;
    this.paint.setStyle(Paint.Style.STROKE);
  }

  private void updatePoints()
  {
    this.cnX = (this.node.getNodeX() + this.node.getNodeWidth() / 2.0F);
    this.cnY = (this.node.getNodeY() + this.node.getNodeHeight() / 2.0F);
    this.cpX = (this.parent.getNodeX() + this.parent.getNodeWidth() / 2.0F);
    this.cpY = (this.parent.getNodeY() + this.parent.getNodeHeight() / 2.0F);
    this.parentP = this.parent.getLineConnection(this.cnX, this.cnY);
    this.parentX = this.parentP.x;
    this.parentY = this.parentP.y;
    this.childP = this.node.getLineConnection(this.cpX, this.cpY);
    this.nodeX = this.childP.x;
    this.nodeY = this.childP.y;
  }

  public RelativeLayout.LayoutParams getRelativeLayoutParams()
  {
    updatePoints();
    this.b = Math.round(3.0F * this.commonResources.getZoom());
    RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(Math.abs(this.nodeX - this.parentX), Math.abs(this.nodeY - this.parentY));
    localLayoutParams.leftMargin = (Math.min(this.nodeX, this.parentX) - this.b);
    localLayoutParams.topMargin = (Math.min(this.nodeY, this.parentY) - this.b);
    return localLayoutParams;
  }

  protected void onDraw(Canvas paramCanvas)
  {
	boolean check = true;
    super.onDraw(paramCanvas);
    this.paint.setColor(this.parent.attributes.getBorderColor());
    this.paint.setStrokeWidth(3.0F * this.commonResources.getZoom());
    this.w = Math.abs(this.nodeX - this.parentX);
    this.h = Math.abs(this.nodeY - this.parentY);
    int i = Math.round(3.0F * this.commonResources.getZoom() / 2.0F);
    if ((!this.node.doesIntersect(this.parentX, this.parentY)) && (!this.parent.doesIntersect(this.nodeX, this.nodeY)))
    {
      if (((this.nodeX <= this.parentX) || (this.nodeY <= this.parentY)) && ((this.parentX <= this.nodeX) || (this.parentY <= this.nodeY)))
    	  check = false;
        //break label281;
      this.path.reset();
      this.path.moveTo(i, i);
      this.path.cubicTo(i + Math.round(this.w / 4), i + Math.round(this.h / 2), i * 2 + Math.round(3 * this.w / 4), i * 2 + Math.round(this.h / 2), i * 3 + this.w, i * 3 + this.h);
      paramCanvas.drawPath(this.path, this.paint);
    }
    while (true)
    {
      //return;
      this.path.reset();
      this.path.moveTo(i, this.h + i * 3);
      this.path.cubicTo(i + Math.round(this.w / 4), i + Math.round(this.h / 2), i * 2 + Math.round(3 * this.w / 4), i * 2 + Math.round(this.h / 2), i * 3 + this.w, i);
      paramCanvas.drawPath(this.path, this.paint);
      return;
    }
  }

  protected void onMeasure(int paramInt1, int paramInt2)
  {
    this.w = Math.abs(this.nodeX - this.parentX);
    this.h = Math.abs(this.nodeY - this.parentY);
    this.t = Math.round(3.0F * this.commonResources.getZoom());
    this.b = Math.round(3.0F * this.commonResources.getZoom() / 2.0F);
    if (this.w < this.t)
      this.w = this.t;
    if (this.h < this.t)
      this.h = this.t;
    setMeasuredDimension(this.w + 4 * this.b, this.h + 4 * this.b);
  }

  public void updateLayoutParams()
  {
    updatePoints();
    this.b = Math.round(3.0F * this.commonResources.getZoom());
    RelativeLayout.LayoutParams localLayoutParams = new RelativeLayout.LayoutParams(Math.abs(this.nodeX - this.parentX), Math.abs(this.nodeY - this.parentY));
    localLayoutParams.topMargin = (Math.min(this.nodeY, this.parentY) - this.b);
    localLayoutParams.leftMargin = (Math.min(this.nodeX, this.parentX) - this.b);
    setLayoutParams(localLayoutParams);
  }
}

/* Location:           D:\APKtoJava_RC2\tools\classes-dex2jar.jar
 * Qualified Name:     com.qdvsoftworks.schematicmind.nodes.Line
 * JD-Core Version:    0.6.0
 */